/* helpers */
static char*
-nmn4_concat(char* arg0, ...)
+nmn4_concat(const char* arg0, ...)
{
va_list args;
char* src, *res;
res = xstrappend(res, c);
}
}
- xfree(src);
+// xfree(src);
src = va_arg(args, char*);
}
va_end(args);
nmn4_read_data(void)
{
char* buff;
- char* str, *c;
+ char* str;
+ QString c;
int column;
int line = 0;
- char* zip1, *zip2, *city, *street, *number;
+ QString zip1, zip2, city, street, number;
route_head* route;
waypoint* wpt;
nmn4_check_line(buff);
/* for a quiet compiler */
- zip1 = zip2 = city = street = number = NULL;
+ zip1 = zip2 = city = street = number = QString();
wpt = waypt_new();
column = -1;
- c = csv_lineparse(str, "|", "", column++);
+ c = QString::fromLatin1(csv_lineparse(str, "|", "", column++));
while (c != NULL) {
switch (column) {
case 0: /* "-" */ /* unknown fields for the moment */
break;
case 4: /* ZIP Code */
- if (*c != '-') {
- zip1 = xstrdup(c);
- } else {
- zip1 = xstrdup("");
+ if (c[0] != '-') {
+ zip1 = c;
}
break;
case 5: /* City */
- if (*c != '-') {
- city = xstrdup(c);
- } else {
- city = xstrdup("");
+ if (c[0] != '-') {
+ city = c;
}
break;
case 6: /* ZIP Code -2- */
- if (*c != '-') {
- zip2 = xstrdup(c);
- } else {
- zip2 = xstrdup("");
+ if (c[0] != '-') {
+ zip2 = c;
}
break;
case 7: /* Street */
- if (*c != '-') {
- street = xstrdup(c);
- } else {
- street = xstrdup("");
+ if (c[0] != '-') {
+ street = c;
}
break;
case 8: /* Number */
- if (*c != '-') {
- number = xstrdup(c);
- } else {
- number = xstrdup("");
+ if (c[0] != '-') {
+ number = c;
}
/*
- This is our final index
+ This is our final index
All stuff for generating names or comments
is hold locally.
Instead we construct a description from that.
*/
- if (strcmp(zip1, zip2) == 0) {
- *zip2 = '\0';
+ if (zip1 == zip2) {
+ zip2 = QString();
}
- if (*city != '\0') {
+ if (!city.isEmpty()) {
/*
if any field following city has a value, add a comma to city
*/
- if ((*street != '\0') || (*number != '\0') || (*zip2 != '\0')) {
- city = xstrappend(city, ",");
+ if (!street.isEmpty() || !number.isEmpty() || !zip2.isEmpty()) {
+ city += ",";
}
}
/* concats all fields to one string and release */
- wpt->description = nmn4_concat(zip1, city, street, number, zip2, NULL);
+#if NEW_STRINGS
+ wpt->description = zip1.trimmed() + " " +
+ city.trimmed() + " " +
+ street.trimmed() + " " +
+ number.trimmed() + " " +
+ zip2.trimmed();
+#else
+ wpt->description = nmn4_concat(CSTR(zip1), CSTR(city), CSTR(street), CSTR(number), CSTR(zip2), NULL);
+#endif
break;
case 11: /* longitude */
- sscanf(c, "%lf", &wpt->longitude);
+ wpt->longitude = c.toDouble();
break;
case 12: /* latitude */
- sscanf(c, "%lf", &wpt->latitude);
+ wpt->latitude = c.toDouble();
break;
}
- c = csv_lineparse(NULL, "|", "", column++);
+ c = QString::fromLatin1(csv_lineparse(NULL, "|", "", column++));
}
route_add_wpt(route, wpt);
}